package com.zhan.signalling.message;

import java.util.Map;

import com.google.common.collect.Maps;

public enum AccoutType {
	
	
	ADMIN(0,"admin"),
	MANAGER(1,"manager"),
	PARTICIPANT(2,"participant"),
	GUEST(3,"guest");
	
	private static Map<Integer,AccoutType> instanceMap;
	
	private static Map<String,AccoutType> instanceMap1;
	
	static {
		instanceMap = Maps.newHashMap();
		instanceMap.put(ADMIN.type, ADMIN);
		instanceMap.put(MANAGER.type, MANAGER);
		instanceMap.put(PARTICIPANT.type, PARTICIPANT);
		instanceMap.put(GUEST.type, GUEST);
		
		instanceMap1 = Maps.newHashMap();
		instanceMap1.put(ADMIN.name, ADMIN);
		instanceMap1.put(MANAGER.name, MANAGER);
		instanceMap1.put(PARTICIPANT.name, PARTICIPANT);
		instanceMap1.put(GUEST.name, GUEST);
	}
	
	private Integer type;
	
	private String name;
	
	private AccoutType(Integer type, String name) {
		this.type = type;
		this.name = name;
	}

	public Integer getType() {
		return type;
	}
	
	public String getName() {
		return name;
	}

	public static AccoutType getInstance(Integer type) {
		return instanceMap.get(type);
	}
	
	public static AccoutType getInstance(String name) {
		return instanceMap1.get(name);
	}
}
